#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include "stdafx.h"
#include "FCFile.h"
#include "SkiaHost.h"
#include "SkiaPaint.h"

int main() {
	std::locale::global(std::locale(""));
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Init(SDL_INIT_TIMER);
	TTF_Init();
	SDL_Window* window = SDL_CreateWindow("My Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 700, 700, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
	FCNative *native = new FCNative();
	SkiaPaint *paint = new SkiaPaint();
	paint->m_render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
	SkiaHost *host = new SkiaHost();
	host->m_window = window;
	native->setPaint(paint);
	host->setNative(native);
	native->setHost(host);
	FCSize nativeSize = {700, 700};
	native->setSize(nativeSize);
	FCRect drawRect = {0, 0, nativeSize.cx, nativeSize.cy};
	host->m_clientSize = nativeSize;
	FCUIXml *xml = new FCUIXml();
	xml->setNative(native);
	xml->loadFile(L"mainframe.xml", 0);
	native->update();
	native->invalidate();
	host->onMessage();
	SDL_DestroyRenderer(paint->m_render);
	SDL_DestroyWindow(window);
	TTF_Quit();
	SDL_Quit();
	return 0;
}

